package cn.echoedu.specifics;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;

import cn.echoedu.daoconstants.TableName;
import cn.echoedu.entity.AClass;
import cn.echoedu.entity.Department;
import cn.echoedu.entity.ReceiveSchoolNotify;
import cn.echoedu.entity.SchoolNotify;
import cn.echoedu.entity.User;
import cn.echoedu.util.L;
import cn.echoedu.util.StringUtil;

public class SpecReceiveSchoolNotify extends BaseSpec{
	private final String T = "SpecReceiveSchoolNotify***********>>";
	@Override
	public <T> PreparedStatement getPreparedInsert(Connection con,
			TableName tableName, T currentPojo) throws SQLException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public <T> PreparedStatement getPreparedInsertRunning(Connection con,
			TableName tableName, T currentPojo) throws SQLException {
		// TODO Auto-generated method stub
		L.gpir(T);
		ReceiveSchoolNotify receiveschoolnotify = (ReceiveSchoolNotify)currentPojo;
		String sql = "insert into receiveschoolnotify" +
				"(receiveusernumber,schoolnotifyid,receiveclasscode," +
				"schoolnotifyisdefault,receivedepartmentcode) values" +
				StringUtil.getBeforeTheBsrackets()+"?,?,?,?,?"
				+StringUtil.getAfterTheBrackets();
		PreparedStatement preparedstatement = con.prepareStatement(sql);
		if(receiveschoolnotify.getUser()!=null&&receiveschoolnotify.getUser()
				.getUsernumber()!=null){
			preparedstatement.setString(1,receiveschoolnotify.getUser().getUsernumber());
		}else{
			preparedstatement.setNull(1,Types.INTEGER);
		}
		if(receiveschoolnotify.getSchoolnotify()!=null&&
				receiveschoolnotify.getSchoolnotify().getSchoolnotifyid()!=0){
			preparedstatement.setInt(2,receiveschoolnotify.getSchoolnotify().getSchoolnotifyid());
		}else{
			preparedstatement.setNull(2, Types.INTEGER);
		}
		if(receiveschoolnotify.getAclass()!=null&&receiveschoolnotify.getAclass().getClasscode()!=0){
			preparedstatement.setInt(3,receiveschoolnotify.getAclass().getClasscode());
		}else{
			preparedstatement.setNull(3,Types.INTEGER);
		}
		preparedstatement.setInt(4,receiveschoolnotify.getSchoolnotifyisdefault());
		if(receiveschoolnotify.getDepartment()!=null&&receiveschoolnotify.getDepartment().getDepartmentcode()!=0){
			preparedstatement.setInt(5,receiveschoolnotify.getDepartment().getDepartmentcode());
		}else{
			preparedstatement.setNull(5,Types.INTEGER);
		}
        return preparedstatement;
	}

	@Override
	public Object getPojo(ResultSet rs) throws SQLException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public <T> PreparedStatement getPreparedUpdate(Connection con,
			TableName tableName, T oldPojo, T currentPojo) throws SQLException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public <T> String getPreparedInsertGetPrimaryKeySql(Connection con,
			TableName tableName, T currentPojo) throws SQLException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Object getLeftJoinPojo(ResultSet rs) throws SQLException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Object getPojoBySql(ResultSet rs) throws SQLException {
		// TODO Auto-generated method stub
		ReceiveSchoolNotify receiveschoolnotify = new ReceiveSchoolNotify();
		receiveschoolnotify.setRecivenotify(rs.getInt(1));
		User user = new User();
		user.setUsernumber(rs.getString(2));
		receiveschoolnotify.setUser(user);
		SchoolNotify schoolnotify = new SchoolNotify();
		schoolnotify.setSchoolnotifyid(rs.getInt(3));
		receiveschoolnotify.setSchoolnotify(schoolnotify);
		Department department = new Department();
		department.setDepartmentcode(rs.getInt(4));
		receiveschoolnotify.setDepartment(department);
		AClass aclass = new AClass();
		aclass.setClasscode(rs.getInt(5));
		receiveschoolnotify.setAclass(aclass);
		receiveschoolnotify.setSchoolnotifyisdefault(rs.getInt(6));
		return receiveschoolnotify;
	}

	@Override
	public <T> PreparedStatement getPreparedListInsert(Connection con,
			TableName tableName, T currentPojo) throws SQLException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public <T> PreparedStatement getPreparedListInsertRunning(Connection con,
			TableName tableName, T currentPojo) throws SQLException {
		// TODO Auto-generated method stub
		return null;
	}
}
